class Solution 
{
public:
    vector<int> maxSlidingWindow(vector<int>& nums, int k)
    {
        priority_queue<pair<int, int>> sliding_heap;     // 值-索引对
        vector<int> ret;
        for (size_t i = 0; i < k; i++)
        {
            sliding_heap.emplace(make_pair(nums[i], i));
        }
        ret.push_back(sliding_heap.top().first);

        for (size_t i = k; i < nums.size(); i++)
        {
            sliding_heap.emplace(make_pair(nums[i], i));
            while (sliding_heap.top().second <= i - k)
            {
                sliding_heap.pop();
            }
            ret.push_back(sliding_heap.top().first);
        }
        return ret;
    }
};